package com.upb.webserver.dao.mapper;

import com.upb.webserver.dao.entity.TbRole;
import com.upb.webserver.dao.entity.TbRoleExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import java.util.List;
import java.util.Optional;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;

public interface TbRoleMapper {

    @Select({ "<script>", "select", TbRoleSqlProvider.ALL_COLUMN_FIELDS, "from tb_role", "where name in", "<foreach collection='roleNameList' item='roleName' open='(' separator=',' close=')'>", "#{roleName}", "</foreach>", "</script>" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR), @Result(column = "name_zh", property = "nameZh", jdbcType = JdbcType.VARCHAR), @Result(column = "status", property = "status", jdbcType = JdbcType.TINYINT), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "description", property = "description", jdbcType = JdbcType.LONGVARCHAR) })
    List<TbRole> listByRoleNameList(@Param("roleNameList") List<String> roleNameList);

    @Select({ "select", TbRoleSqlProvider.ALL_COLUMN_FIELDS, "from tb_role", "where name = #{name,jdbcType=VARCHAR}" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR), @Result(column = "name_zh", property = "nameZh", jdbcType = JdbcType.VARCHAR), @Result(column = "status", property = "status", jdbcType = JdbcType.TINYINT), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "description", property = "description", jdbcType = JdbcType.LONGVARCHAR) })
    Integer selectRoleIdByRoleName(@Param("name") String name);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbRoleSqlProvider.class, method = "countByExample")
    long countByExample(TbRoleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @DeleteProvider(type = TbRoleSqlProvider.class, method = "deleteByExample")
    int deleteByExample(TbRoleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @Delete({ "delete from tb_role", "where id = #{id,jdbcType=INTEGER}" })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @Insert({ "insert into tb_role (name, name_zh, ", "status, create_time, ", "modify_time, description)", "values (#{name,jdbcType=VARCHAR}, #{nameZh,jdbcType=VARCHAR}, ", "#{status,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP}, ", "#{modifyTime,jdbcType=TIMESTAMP}, #{description,jdbcType=LONGVARCHAR})" })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insert(TbRole record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @InsertProvider(type = TbRoleSqlProvider.class, method = "insertSelective")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insertSelective(TbRole record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbRoleSqlProvider.class, method = "selectByExampleWithBLOBs")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR), @Result(column = "name_zh", property = "nameZh", jdbcType = JdbcType.VARCHAR), @Result(column = "status", property = "status", jdbcType = JdbcType.TINYINT), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "description", property = "description", jdbcType = JdbcType.LONGVARCHAR) })
    List<TbRole> selectByExampleWithBLOBs(TbRoleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbRoleSqlProvider.class, method = "selectByExample")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR), @Result(column = "name_zh", property = "nameZh", jdbcType = JdbcType.VARCHAR), @Result(column = "status", property = "status", jdbcType = JdbcType.TINYINT), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP) })
    List<TbRole> selectByExample(TbRoleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @Select({ "select", "id, name, name_zh, status, create_time, modify_time, description", "from tb_role", "where id = #{id,jdbcType=INTEGER}" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR), @Result(column = "name_zh", property = "nameZh", jdbcType = JdbcType.VARCHAR), @Result(column = "status", property = "status", jdbcType = JdbcType.TINYINT), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "description", property = "description", jdbcType = JdbcType.LONGVARCHAR) })
    TbRole selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbRoleSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") TbRole record, @Param("example") TbRoleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbRoleSqlProvider.class, method = "updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") TbRole record, @Param("example") TbRoleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbRoleSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") TbRole record, @Param("example") TbRoleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbRoleSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TbRole record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @Update({ "update tb_role", "set name = #{name,jdbcType=VARCHAR},", "name_zh = #{nameZh,jdbcType=VARCHAR},", "status = #{status,jdbcType=TINYINT},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "modify_time = #{modifyTime,jdbcType=TIMESTAMP},", "description = #{description,jdbcType=LONGVARCHAR}", "where id = #{id,jdbcType=INTEGER}" })
    int updateByPrimaryKeyWithBLOBs(TbRole record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @Update({ "update tb_role", "set name = #{name,jdbcType=VARCHAR},", "name_zh = #{nameZh,jdbcType=VARCHAR},", "status = #{status,jdbcType=TINYINT},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "modify_time = #{modifyTime,jdbcType=TIMESTAMP}", "where id = #{id,jdbcType=INTEGER}" })
    int updateByPrimaryKey(TbRole record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert({ "<script>", "insert into tb_role (name, ", "name_zh, status, ", "create_time, modify_time, ", "description)", "values<foreach collection=\"list\" item=\"detail\" index=\"index\" separator=\",\">(#{detail.name,jdbcType=VARCHAR}, ", "#{detail.nameZh,jdbcType=VARCHAR}, #{detail.status,jdbcType=TINYINT}, ", "#{detail.createTime,jdbcType=TIMESTAMP}, #{detail.modifyTime,jdbcType=TIMESTAMP}, ", "#{detail.description,jdbcType=LONGVARCHAR})</foreach></script>" })
    int batchInsert(List<TbRole> list);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_role
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbRoleSqlProvider.class, method = "getOneByExample")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR), @Result(column = "name_zh", property = "nameZh", jdbcType = JdbcType.VARCHAR), @Result(column = "status", property = "status", jdbcType = JdbcType.TINYINT), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "description", property = "description", jdbcType = JdbcType.LONGVARCHAR) })
    Optional<TbRole> getOneByExample(TbRoleExample example);
}
